#!/usr/bin/python3.8
# -*- coding: utf-8 -*-
# @Time    : 2021/3/1 11:03
# @Author  : zhaohexin
# @Email   : 1483643520@xxx.com
# @File    : production.py
# @Software: PyCharm
# @FileDescription：生产环境配置

import os

from typing import Union, Optional

from pydantic import AnyHttpUrl, BaseSettings, IPvAnyAddress


class Setting(BaseSettings):
    DEBUG: bool = True
    # 项目温江
    TITLE: str = "TestVersatile"
    DESCRIPTION: str = "后端接口调试文档"
    # 文档地址
    DOCS_URL: str = "/api/docs"
    # 文档关联请求数据接口
    OPENAPI_URL: str = "/api/openapi.json"
    # redoc 文档
    REDOC_URL: Optional[str] = "/api/redoc"

    # token过期时间， 分钟
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
    # 生成token的加密算法
    ALGORITHM: str = "HS256"

    # 密码盐
    SECRET_KEY: str = "!@#$%^&*()123456786tf3gdeyiqy"

    # 项目根目录
    BASE_PATH: str = os.path.dirname(os.path.abspath(__file__))

    # Mysql 配置
    MYSQL_USERNAME: str = "root"
    MYSQL_PASSWORD: str = "11111111"
    MYSQL_HOST: Union[AnyHttpUrl, IPvAnyAddress] = "127.0.0.1"
    MYSQL_PORT: int = 3306
    MYSQL_DATABASE: str = "TestVersatile"

    # Mysql 地址
    SQLALCHEMY_DATABASE_URL = f"mysql+mysqlclient://{MYSQL_USERNAME}:{MYSQL_PASSWORD}@" \
                              f"{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DATABASE}?charset=utf8mb4"

    # redis 配置
    REDIS_HOST: str = "127.0.0.1"
    REDIS_PASSWORD: str = "TestVersatile"
    REDIS_DB: int = 0
    REDIS_PORT: int = 6379
    REDIS_URL: str = f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB}?encoding=utf-8"


settings = Setting()

